import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: asus
 * Date: 2024-12-24
 * Time: 10:43
 */
public class RemoveElement {
    public static int removeElement(int[] nums, int val) {
        int count = 0;
        int fast = 0, low = -1;
        while (fast < nums.length) {
            if (nums[fast]!=val) {
                nums[++low] = nums[fast];
                count++;
            }
            fast++;
        }
        return count;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{3, 2, 2, 3};
        removeElement(nums, 3);
    }
}
